{{include file="Manage/header.html"}}
<body>
{{include file="Manage/menu.html"}}
<div class="index_main">
    {{include file="Manage/menu2.html"}}
        <div class="pro_manage">
            <div class="center">
                <div class="query">
                    <!-- <a href="index.php?app=Role&act=manage">角色管理</a> -->
                    <input type="text" name="keyword" placeholder="项目名称、项目创始人姓名" value="{{if $smarty.get.keyword}}{{$smarty.get.keyword}}{{/if}}">
                    <ul>
                        <li>
                            <span>院系：</span>
                            <select name="verify">
                                {{foreach from=$verify item=val key=key}}
                                <option value="{{$key}}" {{if $smarty.get.auditing_1 == $key}}selected="true"{{/if}}>{{$val}}</option>
                                {{/foreach}}
                            </select>
                        </li>
                        <li>
                            <span>cxcyxy：</span>
                            <select name="verify2">
                                {{foreach from=$verify item=val key=key}}
                                <option value="{{$key}}" {{if $smarty.get.auditing_2 == $key}}selected="true"{{/if}}>{{$val}}</option>
                                {{/foreach}}
                            </select>
                        </li>
                        <a href="index.php?app={{$smarty.get.app}}&act={{$smarty.get.act}}" class="dump">清除</a>
                        <button class="search_box">查询</button>
                    </ul>

                    <button class="dowmload">批量下载</button>
                    <button class="comfirm" onclick="filesDownload()">确认下载</button>
                </div>
                <div class="projects">
                    <table>
                        <tr>
                            <th>编号</th>
                            <th>项目名称</th>
                            <th>项目负责人</th>
                            <th>手机号</th>
                            <th>电子邮箱</th>
                            <th>指导老师</th>
                            <th>院系审核情况</th>
                            <th>cxcyxy审核情况</th>
                            <th>操作</th>
                        </tr>
                        {{if $project.data}}
                        {{foreach from=$project.data item=val key=key}}
                        <tr>
                            <td>
                                <span class="number">{{$key+1}}</span>
                                <div class="selected">
                                    <input type="checkbox" id="ck{{$key}}" value="{{$val.id}}" file_path="{{$val.files}}" title="{{$val.project}}({{$val.username}})">
                                    <label for="ck{{$key}}"></label>
                                </div>
                            </td>
                            <td>
                                <a href="index.php?app=Myproject&act=teacher_detail&id={{$val.id}}">{{$val.project}}</a>
                            </td>
                            <td>{{$val.username}}</td>
                            <td>{{$val.number}}</td>
                            <td>{{$val.email}}</td>
                            <td>{{if $val.members.teacher}}{{$val.members.teacher.username}}{{else}}暂无指导老师{{/if}}</td>
                            <td>{{if $val.auditing_1 == '0'}}项目未审核{{elseif $val.auditing_1 == '1'}}审核通过{{elseif $val.auditing_1 == '2'}}审核不通过{{/if}}</td>
                            <td>{{if $val.auditing_2 == '0'}}项目未审核{{elseif $val.auditing_2 == '1'}}审核通过{{elseif $val.auditing_2 == '2'}}审核不通过{{/if}}</td>
                            <td><a href="{{$smarty.const.__PUB__}}{{$val.files}}" target="_blank">下载</a></td>
                        </tr>
                        {{/foreach}}
                        {{/if}}

                    </table>
                    <div class="page">
                        <div class="pager">
                            {{if $pagenav}}
                            {{$pagenav}}
                            {{elseif $page.html}}
                            {{$page.html}}
                            {{elseif $project.page.html}}
                            {{$project.page.html}}
                            {{/if}}
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    $(function(){

        $(".dowmload").click(function(){

            $(".number").toggle();
            $(".selected").toggle();
            if($(".dowmload").text()=="批量下载"){
                $(".dowmload").text("取消");
                $(".comfirm").show();
                $("table").find("th:first").text("选择");
            }else{
                $(".dowmload").text("批量下载");
                $(".comfirm").hide();
                $("table").find("th:first").text("编号");
            }
        });

        //关键字搜索
        $(".search_box ").click(function(){
            searchKeyword();
        });
        $(".query input").keydown(function(e){
            var curkey = e.which;
            if(curkey == 13){
                searchKeyword();
            }
        });

        //院系审核情况
        $("select[name='verify']").change(function(){
            var value = $(this).val();
            url('auditing_1',value);
        })

        //cxcyxy审核情况
        $("select[name='verify2']").change(function(){
            var value = $(this).val();
            url('auditing_2',value);
        })

        if ($('.projects > table tr td').length > 0) {
            $(".projects").css("background","none");
        }else{
            $(".page").hide();
        }
    })


    //批量下载
    function filesDownload(){
        var files = '';
        var title = '';
        $.each($('input:checkbox:checked'),function(){
            files += ","+$(this).attr('file_path');
            title += ","+$(this).attr('title');
        })
        if(files == ''){
            ui.error('请至少选择一个项目！');
            return false;
        }
        $.post('{{"index.php?app=Download&act=filesDownload"|URL}}',{'files':files.substr(1),'title':title.substr(1)},function(result){
            if(result.statusCode=='200'){
                var url = "{{$smarty.const.__PUB__}}"+result.message;
//                url = setURLArg(url,'file_path',result.message);
                document.location.href = url;
            }else if(result.statusCode=='300') ui.error(result.message);
        },'json');
    }

    function searchKeyword(){
        var keyword = $.trim($(".query input").val());
        if(keyword=='')
            ui.alert('请输入要搜索的关键字!');
        else
            url('keyword',keyword);
    }
    function url(key,value){
        var url = "{{$smarty.server.REQUEST_URI}}";
        url = setURLArg(url,key,value);
        document.location.href = url;
    }
</script>
{{include file="Manage/footer.html"}}
